package com.qfhd.soft.cjzcore.UI.MulitRecycle.viewholder;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.qfhd.soft.cjzcore.Core.CJLogger;
import com.qfhd.soft.cjzcore.Model.Task_image_click_type;
import com.qfhd.soft.cjzcore.R;
import com.qfhd.soft.cjzcore.UI.MulitRecycle.bean.Task_image_detail_section_bean;

public class Task_image_detial_section_viewHolder extends BaseViewHolder {
//    @BindView(R.id.task_image_detail_section_index)
    private TextView tx_index;
//    @BindView(R.id.task_image_detail_section_content)
    private TextView tx_content;
//    @BindView(R.id.task_image_detail_section_sample)
    private ImageView img_sample;

    private View mView;

    public Task_image_detial_section_viewHolder(View mView){
        super(mView);
        this.mView = mView;
        tx_index = (TextView)mView.findViewById(R.id.task_image_detail_section_index);
        tx_content = (TextView)mView.findViewById(R.id.task_image_detail_section_content);
        img_sample = (ImageView)mView.findViewById(R.id.task_image_detail_section_sample);
    }
    @Override
    public void bindViewData(Object data) {
        Task_image_detail_section_bean bean = (Task_image_detail_section_bean)data;
        tx_index.setText(bean.getIndex() + "");
        tx_content.setText(bean.getModel().step_text);

        CJLogger.v("step bindViewData model:" + bean.getModel().toString());
        if(!bean.getModel().imageIsEmpty()){
            CJLogger.v("step bindViewData step_image full" );
            img_sample.setVisibility(View.VISIBLE);
            Glide.with(mView)
                    .load(bean.getModel().step_image)
                    .placeholder(bean.getmContext().getResources().getDrawable(R.drawable.empty_placeholder))
                    .into(img_sample);

            img_sample.setOnClickListener(v -> {
                if(bean.getListener() != null){
                    bean.getListener().onClick(Task_image_click_type.ShowImage);
                }
            });
        }
        else{
            CJLogger.v("step bindViewData step_image null" );
            img_sample.setVisibility(View.GONE);
            img_sample.setOnClickListener(null);
        }
    }
}
